package menus;


import connect.druid;

import java.util.Scanner;

/**
 * @author malguy-wang sir
 * @create ${year}-${month}-${day}-${time}
 */
public class B {
    public static void UI(){
        System.out.println("---------------菜单--------------");
        System.out.println("输入数字，选择数字进行操作");
        System.out.println("1，增加");
        System.out.println("2，删除");
        System.out.println("3，修改");
        System.out.println("4，查找");
        System.out.println("5，退出");
    }
    public static void menu()throws Exception{
        Scanner scan = new Scanner(System.in);
        boolean flag = true;
        while (flag){
            UI();
            int choice = scan.nextInt();
            switch (choice) {
                case 1:
                    circle(scan, 1);
                    break;
                case 2:
                    circle(scan, 2);
                    break;
                case 3:
                    circle(scan, 3);
                    break;
                case 4:
                    circle(scan, 4);
                    break;
                case 5:
                    System.out.println("已经退出程序");
                    flag = false;
                    break;
            }
        }
    }
    private static void circle(Scanner scanner, int choice) throws Exception {
        //把循环执行的逻辑防在菜单类，各司其职
            switch (choice) {
                case 1:
                    System.out.println("添加中：......");
                    druid.ins(scanner);
                    break;
                case 2:
                    System.out.println("删除中：......");
                    druid.del(scanner);
                    break;
                case 3:
                    System.out.println("修改中：......");
                    druid.update(scanner);
                    break;
                case 4:
                    System.out.println("查找中：......");
                    druid.select();
                    break;
            }
        }
    }

